package com.globallogic.dmytro_zakharenko.university.enums;

import java.util.ArrayList;

public class LessonNames {

	private static String[] mLessonsName = new String[0];
	private static final String[] mBasicsLessons = {"Astronomy", "1_Course", "Charms", "2_Course", "Dark Arts", "2_Course", "Defence Against the Dark Arts", "2_Course",
									   				"Flying", "1_Course", "Herbology", "1_Course", "History of Magic", "1_Course", "Potions", "2_Course", "Transfiguration", "2_Course",
									   				"Study of Ancient Runes", "3_Course", "Arithmancy", "3_Course", "Muggle Studies", "3_Course", "Care of Magical Creatures","3_Course",
									   				"Divination", "3_Course", "Apparition", "3_Course", "Alchemy", "3_Course", "Ancient Studies", "3_Course", "Art", "1_Course",
									   				"Earth Magic", "2_Course", "Muggle Art", "3_Course", "Music", "2_Course", "Muggle Music", "2_Course", "Ghoul Studies", "1_Course",
									   				"Magical Theory", "1_Course", "Xylomancy", "1_Course", "Frog Choir", "1_Course", "Hogwarts orchestra", "2_Course" };
	
	public static int setBasicLessons() {
		mLessonsName = mBasicsLessons;	
		return mBasicsLessons.length;
	}
	
	/**
     * add lesson to existence lessons
     *
     *@param lessonName 
     *@param lessonCourse  
     */
	public static void addLesson(String lessonName, String lessonCourse) {
		ArrayList<String> less = new ArrayList<String>();
		for (String s : mLessonsName) {
			less.add(s);
		}
		less.add(lessonName);
		less.add(lessonCourse);
		mLessonsName = less.toArray(new String[less.size()]);
	}
	
	/**
     * remove lesson from existence lessons
     *
     *@param lessonName 
     */
	public static void removeLesson(String lessonName) {
		ArrayList<String> less = new ArrayList<String>();
		for (String s : mLessonsName) {
			less.add(s);
		}
		int i = 0;
		for (String l : less) {
			if (l.equalsIgnoreCase(lessonName)) {
				less.remove(i);
				less.remove(i);
				break;
			} 
			i++;
		}
		mLessonsName = less.toArray(new String[less.size()]);
	}	
	
	/**
     * return all lessons from existence lessons
     */
	public static String[] getLessonsName() {
		return mLessonsName;
	}
}